package cn.lili.modules.union.mapper;

import cn.lili.modules.member.entity.dos.UnionMember;
import cn.lili.modules.member.entity.dos.UnionMemberApply;
import cn.lili.mybatis.util.PageUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UnionMemberApplyMapper extends BaseMapper<UnionMemberApply> {

    /**
     * 我的申请 / 会长邀请记录
     * @param memberId
     * @param pageStart 分页
     * @param pageSize 每页大小
     * @param optype 操作类型（申请，邀请)
     * @return
     */
    @Select("select ap.*,un.union_name,ur.nick_name as chairmanName," +
            "ur.face as chairmanPortrait,(select count(1) from li_union_member m where m.union_id = un.id) as memberCount " +
            "from li_union_member_apply ap " +
            "inner join li_union un on ap.union_id=un.id " +
            "left join li_user ur on ur.id = un.chairman_id " +
            "${ew.customSqlSegment}")
    Page<UnionMemberApply> getByPage(Page page,@Param(Constants.WRAPPER) Wrapper<UnionMemberApply> queryWrapper);




    /**
     * 入会申请记录 / 会长邀请记录
     * @return
     */
    @Select("select ap.*,un.union_name,ur.nick_name as memberName," +
            "ur.face as memberHead " +
            "from li_union_member_apply ap " +
            "inner join li_union un on ap.union_id=un.id " +
            "left join li_user ur on ur.id = ap.member_id " +
            "${ew.customSqlSegment}")
    Page<UnionMemberApply> getJoinRecordsByPage(Page page,@Param(Constants.WRAPPER) Wrapper<UnionMemberApply> queryWrapper);
}
